//
//  ContentView.swift
//  NJU QR
//
//  Created by 许煜恒 on 8/11.
//

import SwiftUI
import WatchConnectivity



struct ContentView: View {
    @Environment(\.colorScheme) var appearance
    
    @AppStorage("login_cookie")
    private var login_cookie: String?
    //example: "CASTGC=TGT-196633-FhxLaCBjUpo5jGKissddlv4FRrhgrtyhvzUqfdxcswgrvdsfbs916653456435-wMv1-cas;"
    @State private var showSettings: Bool=false
    
    var body: some View {
        VStack{
            Spacer()
            
            QRCodePresentationView(result: getQrContentAsync(login_cookie: login_cookie ?? ""))
//            QRCodeView(qr_content: test_qr_content)
                .scaledToFill()
                .padding()
            
            Spacer()
            
            Button{
                showSettings.toggle()
            } label: {
                Label("", systemImage: "gear")
                    
            }
                .sheet(isPresented: $showSettings) {
                    SettingsView()
                }
                
        }
        .onAppear {
            doTransmission()
        }
        
    }
}

struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView()
            .previewDevice("Apple Watch Series 7 - 45mm")
    }
}



